package demo.practice.binary_search;

public class P367 {

    public static void main(String[] args) {
        P367 p367= new P367();
        p367.isPerfectSquare(16);
        System.out.println((1<<31)-1);
    }

    public boolean isPerfectSquare(int num) {
        long numl = num;
        long min = 0;
        long max = Math.min(numl, 1 << 16);//  int的最大值为( 1<<31 )-1 是小于1<<32 ,所以max不吭呢大于1<<16

        while (min <= max) {
            long mid = min + (max - min) / 2;
            if (mid * mid == numl)
                return true;
            else if (mid * mid > numl)
                //说明 mid偏大
                max=mid-1;
            else
                //说明mid偏小
               min=mid+1;
        }
        return false;
    }

//    public boolean isPerfectSquare(int num) {
//
//    }

}
